Skip to content

feat: automated quota steering + sonnet repin for execution agents#121

Merged
arzafran merged 2 commits into
mainfrom
feat/quota-steering
Jul 6, 2026
Merged

feat: automated quota steering + sonnet repin for execution agents#121
arzafran merged 2 commits into
mainfrom
feat/quota-steering

Conversation

@arzafran

@arzafran arzafran commented Jul 6, 2026

Copy link
Copy Markdown
Member

What this does

Claude Code only exposes your real usage numbers to the statusline — nothing else can see them, so all the "route by headroom" guidance in our docs was advisory prose the model could ignore. This PR makes it enforced: sessions now get an automatic in-context nudge to route bulk work to Codex (or downshift to Sonnet) the moment usage actually gets high, and the two biggest token-consuming agents move off the scarce Opus pool.

Summary

  • statusline.ts persists rate_limits (5-hour + weekly) to ~/.claude/tmp/rate-limits.json on every refresh, and renders the previously-ignored weekly percentage as a wk% badge at ≥50%
  • New src/lib/quota.ts — pure band logic (elevated at 60% 5h / 65% weekly, critical at 85%) with unit tests
  • New src/hooks/quota-steer.ts (UserPromptSubmit) — injects routing guidance on band upgrade, re-reminds every 30 min at critical, resets on return to normal; reads the cached Codex verdict to pick between "batch into Codex" and "downshift to sonnet"; fail-open on missing/stale (>10 min) cache
  • implementer opus→sonnet, reviewer opus[1m]→sonnet; planner/maestro/security-reviewer stay top-tier (gate decisions)
  • Docs updated: agent-models (incl. Fable promo status), codex-bridge, CLAUDE-FULL, codex skill
  • scripts-smoke.test.ts checkpoint fixture hardened: fails loudly and disables gpg signing/hooks so it survives machines with global commit.gpgsign=true

Test Plan

  • bun test — 767 pass, 0 fail (includes new tests/quota.test.ts)
  • bun run typecheck, bun run lint, bun run lint:skills clean
  • End-to-end smoke in isolated HOME: elevated + codex-available, critical escalation, band throttling, garbage stdin fail-open, malformed verdict falls back to unknown
  • After install: re-run setup.sh so the hooks fingerprint covers the new quota-steer registration

arzafran added 2 commits July 6, 2026 16:24
Statusline persists rate_limits to ~/.claude/tmp/rate-limits.json on every
refresh and shows a weekly wk% badge at >=50%. New quota-steer
UserPromptSubmit hook reads the cache, computes a band (elevated at
60% 5h / 65% weekly, critical at 85%), and injects routing guidance:
bulk work to Codex when the bridge is available, sonnet downshift when
not. Emits on band upgrade only, re-reminds every 30min at critical,
fails open on missing/stale cache.
…uting

Execution and diff-reading move to the roomy Sonnet 5 pool; planner,
maestro, and security-reviewer stay top-tier for gate decisions.
Docs updated for the automated steering mechanism and the Fable promo
window status.
@arzafran arzafran merged commit a66cea2 into main Jul 6, 2026
15 checks passed
@arzafran arzafran deleted the feat/quota-steering branch July 7, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant